<html>
<head><meta charset="utf-8"><title>Attributes in MIR · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html">Attributes in MIR</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226239576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226239576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226239576">(Feb 13 2021 at 11:02)</a>:</h4>
<p>Does anyone know if there is an RFC which would allow accessing statment / expression attributes in MIR? If not does that seem like something that might interest people?</p>



<a name="226239619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226239619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226239619">(Feb 13 2021 at 11:03)</a>:</h4>
<p>I've currently hacked around this limitation in my work by inserting closures to which i attach attributes</p>



<a name="226239665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226239665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226239665">(Feb 13 2021 at 11:04)</a>:</h4>
<p>but i'm surprised that no one has found a use for statement attributes as hints for codegen or other down-the-pipeline operations</p>



<a name="226245431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226245431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226245431">(Feb 13 2021 at 13:38)</a>:</h4>
<p>I don't think RFCs are normally defined in terms of the compiler implementation. By "attributes in mir" do you mean attributes on expressions and statements? Or like a fork of the compiler with <code>rustc_private</code> using the MIR internals?</p>



<a name="226247728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226247728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226247728">(Feb 13 2021 at 14:36)</a>:</h4>
<p>Can expressions currently have attributes?</p>



<a name="226247798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226247798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226247798">(Feb 13 2021 at 14:39)</a>:</h4>
<p>yes, but its unstable.</p>



<a name="226253245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226253245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226253245">(Feb 13 2021 at 16:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/122651-general/topic/Attributes.20in.20MIR/near/226247798">said</a>:</p>
<blockquote>
<p>yes, but its unstable.</p>
</blockquote>
<p><a href="https://doc.rust-lang.org/reference/expressions.html#expression-attributes">sometimes</a></p>



<a name="226270977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226270977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226270977">(Feb 13 2021 at 22:05)</a>:</h4>
<p>Joshua: In my case it's because I have a custom compiler driver which uses <code>rustc_private</code> and I would like to communicate from source with my backend</p>



<a name="226271084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226271084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226271084">(Feb 13 2021 at 22:06)</a>:</h4>
<p>but I guess I'm just surprised that it seems like a non-issue so far, that there's been no need to allow programmers to communicate specific hints or intent down to codegen level</p>



<a name="226271130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226271130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226271130">(Feb 13 2021 at 22:06)</a>:</h4>
<p><code>#[inline]</code> works on closures</p>



<a name="226271858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226271858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226271858">(Feb 13 2021 at 22:12)</a>:</h4>
<p>yea I should say, with the exception of closures. They keep their attributes since they have a <code>DefId</code> down in MIR</p>



<a name="226271868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Attributes%20in%20MIR/near/226271868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Attributes.20in.20MIR.html#226271868">(Feb 13 2021 at 22:13)</a>:</h4>
<p>which is how I'm able to abuse them to communicate more information</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>